Package-level declarations

Types

Link copied to clipboard
interface AiModel<M> : ModelMetadata

Wraps a lower level AI model and allows metadata to be attached to a model

Link copied to clipboard

Choose an LLM automatically: For example, in a platform, based on runtime analysis, or based on analysis of the prompt

Link copied to clipboard

Select an LLM by role

Link copied to clipboard
class CharacterHeuristicTokenCountEstimator constructor(val charsPerToken: Int = DEFAULT_CHARS_PER_TOKEN) : TokenCountEstimator<String>

Estimates token count by dividing character length by a configurable characters-per-token ratio. The default ratio of 4 approximates tokenization for English text across most LLM tokenizers. Callers working with non-Latin scripts or code may supply a different ratio.

Link copied to clipboard

The platform's own EmbeddingRoleResolver, consulted after any the application registers.

Link copied to clipboard
class ConfigurableModelProvider constructor(llms: List<LlmService<*>>, embeddingServices: List<EmbeddingService>, properties: ConfigurableModelProviderProperties, roleResolvers: List<RoleResolver> = emptyList(), credentialLlmServiceFactories: List<CredentialLlmServiceFactory> = emptyList(), embeddingRoleResolvers: List<EmbeddingRoleResolver> = emptyList(), credentialEmbeddingServiceFactories: List<CredentialEmbeddingServiceFactory> = emptyList(), localModelCatalogs: List<LocalModelCatalog> = emptyList()) : ModelProvider

Take LLM definitions from configuration

Link copied to clipboard
data class ConfigurableModelProviderProperties(var llms: Map<String, String> = emptyMap(), var embeddingServices: Map<String, String> = emptyMap(), var defaultLlm: String = "gpt-5.6-luna", var defaultEmbeddingModel: String? = null, var roles: Map<String, Map<String, LlmOptions>> = emptyMap(), var credentialServiceCacheSize: Int = 500, var embeddingRoles: Map<String, Map<String, String>> = emptyMap())

Configuration properties for the model provider

Link copied to clipboard
class ConfigurableRoleResolver(properties: ConfigurableModelProviderProperties, defaultProviderName: () -> String?) : RoleResolver

The platform's own RoleResolver, consulted after any the application registers.

Link copied to clipboard

Builds an EmbeddingService from a user-supplied key.

Link copied to clipboard
sealed interface CredentialEndpoint

Where a user's key should be sent, and what the service built from it should say about itself.

Link copied to clipboard

Says where a user's key should be sent, for the providers this application knows about.

Link copied to clipboard

Builds an LlmService from a user-supplied key, for a wire protocol the framework has no client for.

Link copied to clipboard
@ApiStatus.Experimental
class DecisionServiceRegistry

Registered decision and classification services with their family defaults and role bindings.

Link copied to clipboard

Do not use in production code, this is just a lowest common denominator and example.

Link copied to clipboard
sealed interface EmbeddingRoleResolution

What an embedding role resolved to.

Link copied to clipboard
fun interface EmbeddingRoleResolver

Decides what an embedding role means for a given call.

Link copied to clipboard

Embed text in vector space

Link copied to clipboard
Link copied to clipboard
data class EmbeddingServiceMetadataImpl(val name: String, val provider: String, val pricingModel: PricingModel? = null) : EmbeddingServiceMetadata
Link copied to clipboard

Common hyperparameters for LLMs.

Link copied to clipboard

Metadata about a Large Language Model (LLM).

Link copied to clipboard
data class LlmOptions constructor(var modelSelectionCriteria: ModelSelectionCriteria? = null, var model: String? = null, var role: String? = null, var temperature: Double? = null, var frequencyPenalty: Double? = null, var maxTokens: Int? = null, var presencePenalty: Double? = null, var topK: Int? = null, var topP: Double? = null, var thinking: Thinking? = null, var timeout: Duration? = null, extensions: Map<String, Any> = emptyMap()) : LlmHyperparameters

Portable LLM options.

Link copied to clipboard

Shared configuration options for all AI model providers. These properties apply across OpenAI, Anthropic, Bedrock, etc.

Link copied to clipboard
interface ModelMetadata

Metadata about an AI model. Pure data.

Link copied to clipboard
interface ModelProvider

Provide AI models for requested roles, and expose data about available models.

Link copied to clipboard
data class ModelSelectionContext(val userId: String? = null, val credential: ProviderCredential? = null)

What a RoleResolver gets to decide with, beyond the role name itself.

Link copied to clipboard

Makes the ModelSelectionContext for the current call available to model resolution without threading it through every LLM API. Applications set it at their request boundary - a servlet filter, an interceptor, or around the code that starts an agent process.

Link copied to clipboard
sealed interface ModelSelectionCriteria

Superinterface for model selection criteria

Link copied to clipboard

Model families. External exhaustive switches must handle newly introduced families.

Link copied to clipboard

Per-call native structured-output mode.

Link copied to clipboard

Exception thrown when no suitable model is found for the given criteria.

Link copied to clipboard

Convert our LLM options to Spring AI ChatOptions.

Link copied to clipboard
class PerTokenPricingModel(val usdPer1mInputTokens: Double, val usdPer1mOutputTokens: Double) : PricingModel
Link copied to clipboard

Pre-resolved model selection criteria that wraps an already-resolved service instance, bypassing ModelProvider resolution. Useful when the caller already has a concrete service instance, for example in BYOK (bring your own per-user key) scenarios, testing, or dynamic provider selection. The generic type parameter provides compile-time safety at the construction site, while the resolution site uses a single localized cast.

Link copied to clipboard
interface PricingModel

Represents a pricing model for an LLM. The models are usually per token pricing, differentiating between input and output tokens, or all you can eat, where there's an hourly rate for the model running whether or not it is in use. See OpenAI pricing

Link copied to clipboard
data class ProviderCredential(val provider: String, val apiKey: String)

An API key for a named provider, supplied by a user rather than by deployment configuration.

Link copied to clipboard
sealed interface RoleResolution

What a role resolved to.

Link copied to clipboard
fun interface RoleResolver

Decides what a role means for a given call.

Link copied to clipboard
@ApiStatus.Experimental
class ServiceSelectionException(val reason: ServiceSelectionException.Reason, message: String) : IllegalStateException

Thrown when a service selection cannot be satisfied. The message names the request, the services and roles available to the family, the family default and the setting that fixes the selection.

Link copied to clipboard
@ApiStatus.Experimental
interface ServiceSelector<S : ModelMetadata>

Selects a service of one family by registration name, by role, by the family default, or by a supplied instance.

Link copied to clipboard
data class SpringAiEmbeddingService(val name: String, val provider: String, val model: <Error class: unknown class>, val configuredDimensions: Int? = null, val pricingModel: PricingModel? = null) : EmbeddingService, AiModel<<Error class: unknown class>>

Wraps a Spring AI EmbeddingModel exposing an embedding service.

Link copied to clipboard
class Thinking

Thinking config. Set on Anthropic models and some Ollama models.

Link copied to clipboard
fun interface TokenCountEstimator<T>

Estimate the number of tokens in content of type T. Implementations must be thread-safe, stateless, and never throw. Always returns >= 0.

Link copied to clipboard
@ApiStatus.Experimental
object TransportFailureDiagnostics

Bounded transport categories for diagnostics. These do not choose a retry policy or a result. Unknown exception types produce other; exception messages never become category values. Adapter-specific invalid-response and SDK rate-limit recognition belong to the caller.

Properties

Link copied to clipboard

Extension key for native structured-output overrides in LlmOptions.extensions.

Link copied to clipboard
const val ONE_MILLION: Double = 1000000.0

Functions

Link copied to clipboard

Read the native structured-output mode from LlmOptions.

Link copied to clipboard

Attach a native structured-output mode to LlmOptions.